Interactive Data Visualization

Row

Attrition Count

Attrition

Number of Employee Data Reviewed

1470

Monthly Income

Yes on Attrition

237

No on Attrition

1233

Row

Data Table

Pivot Table - Numeric

Pivot Table - Categorical

About Report

Project By:Heindel Adu, Stephen Johnson, Ross Fu, Anthony Yeung

Confidential: HIGHLY!

---
title: "Attrition Predictor Analysis"

output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: fill
    social: ["github","linkedin", "twitter", "facebook", "menu"]
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(knitr)
library(DT)
library(rpivotTable)
library(ggplot2)
library(plotly)
library(dplyr)
library(openintro)
library(highcharter)
library(ggvis)
```


```{r}
#"data" has categorical data converted to numerical
# "data2" has a mixed data types
data <- read.csv("~/Documents/Projects/SMU/rProjects/CaseStudy_02/CaseStudy_02/NumData.csv")
data2 <- read.csv("~/Documents/Projects/SMU/rProjects/CaseStudy_02/CaseStudy_02/CaseStudy2-data.csv")
View(data)
#str(data)
```

```{r}
mycolors <- c("blue", "#FFC125", "darkgreen", "darkorange", "darkblue")
```

Interactive Data Visualization
=====================================
Row
-------------------------------------
### Attrition Count

```{r}
valueBox(paste("Attrition"),
         color = "darkblue")
#unique.(data$Attrition)

#data %>%
#  summarise(Attrition = n())
```

### Number of Employee Data Reviewed

```{r}

valueBox(length(data$Attrition),
         icon = "fa-users")
```

### **Monthly Income**
```{r}
gauge(round(min(data$MonthlyIncome),
            digits = 2),
            min = 0,
            max = 25000,
      label = "Min Monthly Income",
            gaugeSectors(success = c(15000, 25000),
                         warning = c(5000,15000),
                         danger = c(0, 5000),
                         colors = c("green", "yellow", "red")))
```

```{r}
gauge(round(mean(data$MonthlyIncome),
            digits = 2),
            min = 0,
            max = 25000,
       label = "Avg Monthly Income",
            gaugeSectors(success = c(15000, 25000),
                         warning = c(5000,15000),
                         danger = c(0, 5000),
                         colors = c("green", "yellow", "red")))

```

```{r}
gauge(round(max(data$MonthlyIncome),
            digits = 2),
            min = 0,
            max = 25000,
       label = "Max Monthly Income",
            gaugeSectors(success = c(15000, 25000),
                         warning = c(5000,15000),
                         danger = c(0, 5000),
                         colors = c("green", "yellow", "red")))
```

### Yes on Attrition

```{r, Yes}
valueBox(sum(data$Attrition == "Yes"),
         icon = 'fa-user-o')

```


### No on Attrition

```{r, No}
valueBox(sum(data$Attrition == "No"),
         icon = 'fa-user')
```

Row
-------------------------------------------------
```{r}
#summary(data2$Attrition)
#str(data2$Attrition)
#p0 <- ggplot2::data2 %>% sum(JobRole, Attrition) %>%
#  plot_ly(x = ~JobRole, y = ~n, color = ~Attrition)
p1 <- data2 %>%
  group_by(JobRole) %>%
  summarise(count = n()) %>%
  plot_ly(x = ~JobRole,
          y = ~count,
          color = 'blue',
          type = 'bar') %>%
  layout(xaxis = list(title = "Job Role"),
    yaxis = list(title = 'Count'))
p1
#names(data2)
```


Data Table
========================================

```{r}
datatable(data2,
          caption = "Attrition Data",
          rownames = TRUE,
          filter = "top",
          options = list(pageLength = 25))
```

Pivot Table - Numeric
=========================================

```{r}
rpivotTable(data,
            aggregatorName = "Count",
            cols= "Attrition",
            rows = "JobRole",
            rendererName = "Heatmap")
```

Pivot Table - Categorical
=========================================

```{r}
rpivotTable(data2,
            aggregatorName = "Count",
            cols= "Attrition",
            rows = "JobRole",
            rendererName = "Heatmap")
```

About Report
========================================

##Project By:Heindel Adu, Stephen Johnson, Ross Fu, Anthony Yeung
Confidential: HIGHLY!